home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / regkey21.zip / REGKEY.DOC < prev    next >
Text File  |  1992-08-10  |  15KB  |  283 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                    REGISTRATION KEY SYSTEM FOR PROGRAMMERS
  9.                                  Version 2.10
  10.  
  11.  
  12.            (C) Copyright 1992, Brian Pirie. All Rights Reserved.
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.     You are granted permission to use an unmodified version of this code
  21.     in any program, so long as your program's documentation acknowledges
  22.     the use of this code. There is no charge for the use of this
  23.     software.
  24.  
  25.  
  26.  
  27.  
  28.     This brief document describes the accompanying files which can be
  29.     used to easily implement a registration key system in any programs
  30.     which you have written. I would encourage you to read this entire
  31.     file, prior to attempting to use this system - there is some very
  32.     important information contained withing, that may not seem obvious
  33.     prior to reading this document.
  34.  
  35.     First of all, if you are currently using the REGKEY10.* library,
  36.     please note that the new versions 2.00 and later is NOT an upgrade
  37.     from the previous version, but a re-written algorithm. This means
  38.     that the new package will produce different registration key values
  39.     than the old one. Therefore, if you are using REGKEY10 in any of
  40.     your programs, you should not try to recompile the same program
  41.     using this new package.
  42.  
  43.     As of version 2.10, the registration key systems should be
  44.     compatible with any compiler that supports the MicroSoft .OBJect
  45.     code format. While all of the example programs included with this
  46.     package are in C, the package should be compatible with any
  47.     language, including Pascal, BASIC and Assembly language, which
  48.     supports the C function calling convention. The registration key
  49.     system should be compatible with Turbo C(++), Borland C++, MicroSoft
  50.     Quick C, MicroSoft C(++), Turbo Pascal, QuickBASIC, Visual BASIC,
  51.     and many other compilers.
  52.  
  53.     Using this registration key system, you can easily and quickly
  54.     generate and verify the validity of numerical registration keys that
  55.     correspond to a person who has purchased your program. Thus, when
  56.     someone who already has a shareware or demo version of your program
  57.     wishes to purchase the program, you need only send them a simple
  58.     registration key number, instead of sending an entire registered
  59.     version. You can simply use this package to generate a unique
  60.     registration key number which corresponds to the user's name (or any
  61.     other string you wish to use). The user will then be able to enter
  62.     this number into your software's configuration file / configuration
  63.     program. When your program begins, it will be able to read this
  64.     number from the configuration file, and again using this package,
  65.     determine whether it is a valid registration key corresponding to
  66.     the user's name. If the registration key is valid, your program can
  67.     switch into "registered mode", and if not, can run in its
  68.     unregistered "demo" mode.
  69.  
  70.     Unlike other registration key algorithms, this package can be used
  71.     over and over, by many different programs and programmers. Each
  72.     program written to use this package simply provides the registration
  73.     algorithm with its own unique numerical security code. This way, the
  74.     registration key for a user named "Brian Pirie" might be 4042871256
  75.     for one program, while the registration key for "Brian Pirie" could
  76.     be 1732396345 for another program.
  77.  
  78.     Below are detailed instructions for the use of the registration key
  79.     system in C programs. If you wish to use this package with any other
  80.     language, you should still read the rest of this manual. However,
  81.     you will probably also have to refer to other books / manuals for
  82.     instructions on calling C functions from withing whatever language
  83.     you are using.
  84.  
  85.     In order to make use of this registration key system in your
  86.     program, you must take a few simple steps when writing and compiling
  87.     your program:
  88.  
  89.     1.) First of all, you must include the "BP.H" header file in your
  90.         program. This can be accomplished by adding the line:
  91.  
  92.                #include "bp.h"
  93.  
  94.         at the beginning of your program.
  95.  
  96.     2.) Secondly, you must instruct your C compiler to link your program
  97.         with the appropriate BP?.LIB. The library you use should
  98.         correspond to the same memory model you use to compile your
  99.         program. The memory models and their corresponding library files
  100.         are listed below:
  101.  
  102.                 BPT.LIB - Tiny Memory Model
  103.                 BPS.LIB - Small Memory Model
  104.                 BPC.LIB - Compact Memory Model
  105.                 BPM.LIB - Medium Memory Model
  106.                 BPL.LIB - Large Memory Model
  107.                 BPH.LIB - Huge Memory Model
  108.  
  109.         In order to have your program linked with one of these
  110.         libraries, you can create a makefile or project file, which
  111.         lists the name of your program's source code file(s), along with
  112.         the filename of the appropriate libary. For more information on
  113.         doing this, refer to the manuals which came with your compiler.
  114.  
  115.     You will now be able to make use of the registration key function.
  116.     This function's prototype is listed below:
  117.  
  118.       unsigned long bp(char *registration_string, unsigned int security_code);
  119.  
  120.     As you can see, this function accepts two parameters. The first
  121.     parameter, registration_string, is a pointer to the string which
  122.     should be used to generate the registration key. This will usually
  123.     be the name of the person who has registered (purchased) your
  124.     program. The second parameter, security_code, should be a number
  125.     between 0 and 65,535, which should be a unique value for any given
  126.     program you have written. It is this parameter that makes a user's
  127.     registration key unique for your program, and which prevents other
  128.     people who may have this package from producing registration keys
  129.     for use with your program. The bp() function will return the
  130.     registration key corresponding to the registration string and
  131.     security code, as an unsigned long integer. In your registration key
  132.     GENERATION PROGRAM, this is the value which you will display, in
  133.     order to send to the registered user. In the ACTUAL PROGRAM that the
  134.     user is registering, you will compare this value with the value
  135.     supplied by the user in your configuration file / configuration
  136.     program. If and only if these values match, your program should then
  137.     operate in "registered" mode.
  138.  
  139.     You can also make use of the included MAKEKEY program to generate
  140.     registration keys to send to registered users. Run this program by
  141.     simply typing MAKEKEY from the DOS prompt. You will then be prompted
  142.     to enter the unique security code used by your program, and the name
  143.     of the user who has registered. This program will then display the
  144.     registration key corresponding to the supplied registration string
  145.     (user's name). Again, remember that it is the security code which
  146.     prevents other people from creating registration keys for use with
  147.     your program, and as such, it is important that you keep your
  148.     program's security code confedential.
  149.  
  150.     When using this registration key system, be careful not to accept
  151.     registration strings (ie, the user's name) which are empty. The
  152.     registration system will always return the same value for an empty
  153.     string. Thus, you should check the length of the name the user has
  154.     entered, and if it is 0, automatically assume that the user is not
  155.     registered, and do not call the bp() function at all.
  156.  
  157.     The source code to the MAKEKEY program is included in the file
  158.     MAKEKEY.C. Feel free to alter this makekey program in any way you
  159.     wish. For example, you may want to create a custom version of the
  160.     MAKEKEY program for each of your programs in which you use the
  161.     registration key system. You would then be able to hard-code your
  162.     program's security code into your registration key gerneration
  163.     program, to eliminate the need of entering the security code every
  164.     time a user registers.
  165.  
  166.     As an example of the use of the registration key system, say you
  167.     have written a program, and chosen 24805 as your security code. Now,
  168.     when the user registers your program, you would use the MAKEKEY key
  169.     program to generate a registration key which corresponds to the
  170.     exact spelling and capitalization of their name, and send this
  171.     registration key to them. The user would then enter their name,
  172.     exactly how it appeared on their registration form, along with the
  173.     registration key you have sent them, into either a configuration
  174.     file or configuration program. You would then be able to read this
  175.     information from the configuration file, from within your program.
  176.     You program would then determine the registration key which would
  177.     correspond to the user's name, and compare this registration key to
  178.     the key supplied by the user. If the values match, then your program
  179.     would run in registered mode, and if the values do not match, then
  180.     your program would run in unregistered mode. Keep in mind that
  181.     registration keys used in this system are always of type unsigned
  182.     long. Below is an example of part of a program which uses the
  183.     registration key system. This program will read the registration
  184.     information from the file REGISTER.KEY, taking the first line to be
  185.     the name of the registered user, and the second line to be the
  186.     user's registration key. Remember this program uses 24805 as its
  187.     security code - you will want to change this value in any programs
  188.     you write. This is also the value you will have to supply to the
  189.     MAKEKEY program, when generating keys for use with the program
  190.     below. The source code to this program is also listed in the file
  191.     USEKEY.C.
  192.  
  193.         #include "bp.h"      // Include the registration key system header file
  194.  
  195.         #include <stdio.h>                              // Other C header files
  196.         #include <string.h>
  197.  
  198.         char registered=0;                         // 1 if registered, 0 if not
  199.         char registered_name[201];                   // Name of registered user
  200.  
  201.         main()                                         // Main program function
  202.            {
  203.            FILE *fp;                      // File pointer for REGISTER.KEY file
  204.            unsigned long supplied_key;                  // Key supplied by user
  205.            unsigned long correct_key;               // Correct registration key
  206.  
  207.            if((fp=fopen("REGISTER.KEY","r"))!=NULL)         // Try to open file
  208.               {                                                // If successful
  209.               fgets(registered_name,200,fp);             // read name from file
  210.               if(registered_name[strlen(registered_name)-1]=='\n')
  211.                  registered_name[strlen(registered_name)-1]='\0';
  212.  
  213.               fscanf(fp,"%lu",&supplied_key);             // read key from file
  214.  
  215.               fclose(fp);                                         // Close file
  216.  
  217.               correct_key=bp(registered_name,24805);   // Calculate correct key
  218.  
  219.               if(correct_key==supplied_key)  // Compare correct & supplied keys
  220.                  {                                     // If they are identical
  221.                  registered=1;      // Then switch program into registered mode
  222.                  }
  223.               }
  224.  
  225.            if(registered==1)                              // If registered mode
  226.               {                             // Display registration information
  227.               printf("This program is registered to: %s\n",registered_name);
  228.               }
  229.            else if(registered==0)                  // If not in registered mode
  230.               {                             // Display unregistered information
  231.               printf("This program is UNREGISTERED!!!\n");
  232.               }
  233.            }
  234.  
  235.     An alternative means of implementing the registration key system in
  236.     your programs is instead of sending the user a numerical value which
  237.     they enter into your program's configuration, to send them a
  238.     registration key file. This file, similar to that used in the above
  239.     program, would simply contain the user's name and registration key,
  240.     in any format you choose. Your "MAKEKEY" program would then generate
  241.     this file, and your distributed software would read this file, if
  242.     available.
  243.  
  244.     I have decided to make it my policy NOT to release the source code
  245.     for this registration key algorithm. The reason for this is simply
  246.     for the protection of yourself and anyone else wishing to use this
  247.     algorithm in their programs. If the source code to this algorithm
  248.     became widely available, it would be easier (though still next to
  249.     impossible), for someone to be able to produce false registration
  250.     keys for your program. What I can tell you about the algorithm,
  251.     though, is that it uses several steps in the generation of the
  252.     registration key. Each of these steps use a completely different
  253.     approach, in order to provide greater security. Also, the security
  254.     code provided by your program is actually broken down into several
  255.     bit-fields, each of which is used to alter the output of a different
  256.     level of the overall algorithm. As a result, the most security is
  257.     obtained by using a security code which has both high and low bits
  258.     throughout the 16-bit value. As a general rule, try to choose
  259.     security codes above 10000. Also note that the registration string
  260.     can not exceed 200 characters in length.
  261.  
  262.     In no event will I, Brian Pirie, be liable to you for any damages,
  263.     including any lost profits, lost savings, or other incidental or
  264.     consequential damages arising out of the use or inability to use
  265.     this software. While every effort has been made to make this
  266.     registration key system as secure as possible, please remember that
  267.     no such system is fool-proof, and that I can not take any
  268.     responsibility for any difficulties with this software.
  269.  
  270.     I hope you enjoy this package and find it useful. If you are having
  271.     any difficulty with this package, I would be more than happy to
  272.     provide any assistance I can offer. If you would like to get in
  273.     touch with me for any reason at all, please feel more than free to
  274.     do so by any of the following means.
  275.  
  276.     I can be contacted at -   FidoNet : 1:243/8
  277.                              InterNet : Brian.Pirie@f8.n243.z1.fidonet.org
  278.                            Data (BBS) : +1 613 526 4466
  279.                                Postal : 1416 - 2201 Riverside Dr.
  280.                                         Ottawa, Ontario
  281.                                         Canada
  282.                                         K1H 8K9
  283.